/*
 * Copyright 2004 original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jbfilter.bean;

import org.jbfilter.core.FilterComponent;
import org.jbfilter.core.PropertyAccessible;

/**
 * Completes the {@link FilterComponent} contract for JVM side filtering (in memory filtering).
 * @author Marcus Adrian
 * @param <E> the bean type
 * @param <T> the property type
 */
public interface PropertyAccessibleBean <E, T> extends PropertyAccessible {
	/**
	 * The property's value.
	 * @param bean the considered bean
	 * @return the property the filter component is interested in
	 */
	T getPropertyValue(E bean);

	/**
	 * To customize the way how to access the property value.
	 * Direct access, reflection...
	 * Note that this property may modify the inherited {@code propertyPath} property and vice versa.
	 * This is because for the bean implementation of the filter components {@code propertyPath} is used
	 * to create a {@link ReflectionPropertyAccessor} under the hoods. In contrast, for direct property access with an
	 * anonymous implementation of {@link PropertyAccessor}, {@code propertyPath} is not relevant and {@link #getPropertyPath()} will
	 * probably return {@code null}.
	 * @param propertyAccessor
	 */
	void setPropertyAccessor(PropertyAccessor<E, T> propertyAccessor);

}
